package cn.demo.act.domain;

import java.time.LocalDate;
import java.time.LocalTime;
import java.util.List;

import cn.demo.um.domain.UmClientUser;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.mybatisflex.annotation.Column;
import lombok.Data;
import lombok.EqualsAndHashCode;
import com.mybatisflex.annotation.Table;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.core.constant.SqlOperator;
import com.mybatisflex.core.query.SqlOperators;
import cn.demo.common.mybatisFlex.MyInsertListener;
import cn.demo.common.mybatisFlex.MyUpdateListener;
import cn.demo.common.annotation.Excel;
import io.swagger.v3.oas.annotations.media.Schema;
import com.fasterxml.jackson.annotation.JsonIgnore;
import cn.demo.common.core.domain.BaseEntity;
/**
 * 活动管理对象 act_activity_info
 *
 * @author xtjun
 * @date 2024-06-06
 */
@EqualsAndHashCode(callSuper = true)
@Data
@Table(value = "act_activity_info",onInsert = MyInsertListener.class,onUpdate = MyUpdateListener.class)
public class ActActivityInfo extends BaseEntity {
    private static final long serialVersionUID = 1L;

    @Id
    @Schema(description = "id")
    private String id;

    @Excel(name = "活动主题")
    @Schema(description = "活动主题")
    private String subject;

    @Excel(name = "活动详情")
    @Schema(description = "活动详情")
    private String details;

    @Excel(name = "宣传图")
    @Schema(description = "宣传图")
    private String image;

    @JsonFormat(pattern = "yyyy-MM-dd")
    @Excel(name = "活动开始日期", width = 18, dateFormat = "yyyy-MM-dd")
    @Schema(description = "活动开始日期")
    private LocalDate startDate;

    @JsonFormat(pattern = "yyyy-MM-dd")
    @Excel(name = "活动结束日期", width = 18, dateFormat = "yyyy-MM-dd")
    @Schema(description = "活动结束日期")
    private LocalDate endDate;

    @JsonFormat(pattern = "HH:mm")
    @Excel(name = "活动开始时间", width = 18, dateFormat = "HH:mm")
    @Schema(description = "活动开始时间")
    private LocalTime startTime;

    @JsonFormat(pattern = "HH:mm")
    @Excel(name = "活动结束时间", width = 18, dateFormat = "HH:mm")
    @Schema(description = "活动结束时间")
    private LocalTime endTime;

    @Excel(name = "参与人数")
    @Schema(description = "参与人数")
    private Long participantsNumber;

    @Excel(name = "活动地点")
    @Schema(description = "活动地点")
    private String activityAddr;

    @Excel(name = "状态", dictType = "sys_data_status")
    @Schema(description = "状态(字典:sys_data_status)")
    private Integer status;

    @Excel(name = "部门id")
    @Schema(description = "部门id")
    private String deptId;

    @Schema(description = "报名人列表")
    private List<UmClientUser> participants;

    @Schema(description = "是否已经报名")
    @Column(ignore = true)
    private Boolean isApply;

    // 自定义字段的 SQL 操作符
    @JsonIgnore
    public static final SqlOperators operators = new SqlOperators() {{
        set(ActActivityInfo::getSubject, SqlOperator.LIKE);
        set(ActActivityInfo::getDetails, SqlOperator.EQUALS);
        set(ActActivityInfo::getStartDate, SqlOperator.EQUALS);
        set(ActActivityInfo::getEndDate, SqlOperator.EQUALS);
        set(ActActivityInfo::getParticipantsNumber, SqlOperator.EQUALS);
        set(ActActivityInfo::getActivityAddr, SqlOperator.EQUALS);
        set(ActActivityInfo::getStatus, SqlOperator.EQUALS);
        set(ActActivityInfo::getDeptId, SqlOperator.EQUALS);
    }};
}
